package com.binest.universityInformation.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.binest.common.annotation.Log;
import com.binest.common.core.controller.BaseController;
import com.binest.common.core.domain.AjaxResult;
import com.binest.common.enums.BusinessType;
import com.binest.universityInformation.domain.UniversityInformation;
import com.binest.universityInformation.service.IUniversityInformationService;
import com.binest.common.utils.poi.ExcelUtil;
import com.binest.common.core.page.TableDataInfo;

/**
 * 大学信息Controller
 * 
 * @author wwd
 * @date 2024-03-19
 */
@RestController
@RequestMapping("/universityInformation")
public class UniversityInformationController extends BaseController
{
    @Autowired
    private IUniversityInformationService universityInformationService;

    /**
     * 查询大学信息列表
     */
    @PreAuthorize("@ss.hasPermi('universityInformation:universityInformation:list')")
    @GetMapping("/list")
    public TableDataInfo list(UniversityInformation universityInformation)
    {
        startPage();
        List<UniversityInformation> list = universityInformationService.selectUniversityInformationList(universityInformation);
        return getDataTable(list);
    }

    /**
     * 导出大学信息列表
     */
    @PreAuthorize("@ss.hasPermi('universityInformation:universityInformation:export')")
    @Log(title = "大学信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UniversityInformation universityInformation)
    {
        List<UniversityInformation> list = universityInformationService.selectUniversityInformationList(universityInformation);
        ExcelUtil<UniversityInformation> util = new ExcelUtil<UniversityInformation>(UniversityInformation.class);
        util.exportExcel(response, list, "大学信息数据");
    }

    /**
     * 获取大学信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('universityInformation:universityInformation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(universityInformationService.selectUniversityInformationById(id));
    }

    /**
     * 新增大学信息
     */
    @PreAuthorize("@ss.hasPermi('universityInformation:universityInformation:add')")
    @Log(title = "大学信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UniversityInformation universityInformation)
    {
        return toAjax(universityInformationService.insertUniversityInformation(universityInformation));
    }

    /**
     * 修改大学信息
     */
    @PreAuthorize("@ss.hasPermi('universityInformation:universityInformation:edit')")
    @Log(title = "大学信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UniversityInformation universityInformation)
    {
        return toAjax(universityInformationService.updateUniversityInformation(universityInformation));
    }

    /**
     * 删除大学信息
     */
    @PreAuthorize("@ss.hasPermi('universityInformation:universityInformation:remove')")
    @Log(title = "大学信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(universityInformationService.deleteUniversityInformationByIds(ids));
    }
}
